/**
 * $Id: Dialogs.js,v 1.46 2012-07-19 19:09:23 gaudenz Exp $
 * Copyright (c) 2006-2012, JGraph Ltd
 */
/**
 * Constructs a new dialog.
 */



function  UpdateItemDialog(editorUi, graph, cell) {

    var div = document.createElement('div');
    div.appendChild(createItem("System Properties", "", "thtitle"));

    var table = document.createElement('table');
    table.style.width = '100%';
    table.style.height = '100%';
    var tbody = document.createElement('tbody');


    row = document.createElement('tr');

    row.appendChild(createLabel('System Name:'));
    row.appendChild(createIntput(cell.getValue(), "system_name", 'width:100px;'));
    tbody.appendChild(row);


    var morenameold = cell.getValue().replace(" ", "_");


    row = document.createElement('tr');

    row.appendChild(createLabel('Sql-Name:'));
    row.appendChild(createIntput(getValueData("top_system_data." + morenameold, 1)[1], "sql-name", 'width:100px;'));

    tbody.appendChild(row);
    table.appendChild(tbody);
    div.appendChild(table);

    var myUp = mxUtils.button("Update", function() {
        var system_name = $(".system_name").val();

        var sqlname = $(".sql-name").val();

        var morename = system_name.replace(" ", "_");
        $(".top_system_data." + cell.getValue().replace(" ", "_")).remove();

        cell.setValue(system_name);

        graph.refresh();
        graph.refresh();

        var value = "name__sql-name;" + system_name + "__" + sqlname;
        var myadddata = returnInputField("top_system_data " + morename, value);

        $(".itmedata").append(myadddata);


        setSesstion("topolgy_systems", getCells(graph));
        setSesstion("topolgy_systemsEdges", getEdges(graph));
        editorUi.hideDialog();

    });
    div.appendChild(myUp);
    this.container = div;
}
/*
 function VTabsAction(id) {
 
 var myClass = id.replace(" ", "");
 
 $(".alldvs").hide();
 
 $("." + myClass).show();
 
 $(".tabsv").removeClass("selected");
 $("#" + id).addClass("selected");
 
 }
 
 
 var vtasbDivs2 = ["migrate-error-resolve", " synchronise-error-resolve"];
 var vtasbDivs1 = ["migrate", "synchronise-create", "synchronise-update", "user-event", "external-event", "deferred-response"]
 
 function createVerticalTabs2() {
 var alldivs = document.createElement('div');
 
 for (i = 0; i < vtasbDivs2.length; i++) {
 
 
 var divd2 = document.createElement('div');
 
 divd2.setAttribute('class', 'alldvs divt2   ' + vtasbDivs2[i]);
 
 divd2.setAttribute('style', 'display:none;');
 
 var table = document.createElement('table');
 
 
 table.setAttribute('class', 'merTable');
 
 table.style.width = '100%';
 table.style.height = '100%';
 var tbody = document.createElement('tbody');
 
 
 row = document.createElement('tr');
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Event:');
 row.appendChild(td);
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 var myinput = document.createElement('input');
 myinput.setAttribute('class', 'tarns_eventinputs ' + vtasbDivs2[i]);
 myinput.setAttribute('style', 'width:100px;');
 td.appendChild(myinput);
 row.appendChild(td);
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Display Name:');
 row.appendChild(td);
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 myinput = document.createElement('input');
 myinput.setAttribute('class', 'tarns_Display_Names ' + vtasbDivs2[i]);
 myinput.setAttribute('style', 'width:100px;');
 
 td.appendChild(myinput);
 row.appendChild(td);
 tbody.appendChild(row);
 
 row = document.createElement('tr');
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 
 myinput = document.createElement('input');
 
 myinput.setAttribute("type", "checkbox");
 
 myinput.onchange = function() {
 
 
 var tbClass = "merTable";
 
 if ($(this).is(':checked')) {
 
 $("." + tbClass + " .addprow").show()
 } else {
 
 $("." + tbClass + " .addprow").hide()
 
 }
 
 }
 
 
 
 
 myinput.setAttribute('class', 'chadd');
 
 td.appendChild(myinput);
 row.appendChild(td);
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 td.setAttribute('colspan', '3');
 mxUtils.write(td, 'Add Parameters');
 row.appendChild(td);
 tbody.appendChild(row);
 
 
 row = document.createElement('tr');
 row.setAttribute('class', 'addprow');
 row.setAttribute('style', 'display:none');
 
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 td.setAttribute('colspan', '3');
 td.setAttribute('style', ' font-weight: bold;color: blue;');
 mxUtils.write(td, 'EventData');
 row.appendChild(td);
 tbody.appendChild(row);
 
 
 row = document.createElement('tr');
 row.setAttribute('class', 'addprow');
 row.setAttribute('style', 'display:none');
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 myinput = document.createElement('input');
 myinput.setAttribute('class', 'addmore');
 myinput.setAttribute('value', '+');
 myinput.setAttribute('type', 'button');
 
 myinput.setAttribute('id', 'trns');
 var moreData = '<tr class="' + $(this).attr("id") + ' addprow morerow " style="display: table-row;"><td style="font-size: 10pt;">Value:</td><td style="font-size: 10pt;"><input class="' + $(this).attr("id") + '_more_event ' + vtasbDivs2[i] + '" style="width:100px;"></td><td style="font-size: 10pt;">Display Name:</td><td style="font-size: 10pt;"><input class="' + $(this).attr("id") + '_more_DisplayName ' + vtasbDivs2[i] + '" style="width:100px;"></td></tr>';
 
 myinput.onclick = function() {
 
 $(this).parent().parent("tr").after(moreData);
 
 
 }
 
 td.appendChild(myinput);
 
 row.appendChild(td);
 tbody.appendChild(row);
 
 
 
 
 
 row = document.createElement('tr');
 row.setAttribute('class', 'addprow');
 row.setAttribute('style', 'display:none');
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 
 
 td.setAttribute('colspan', '3');
 
 td.setAttribute('style', ' font-weight: bold;color: blue;');
 
 mxUtils.write(td, 'Event - Data pattern');
 
 
 
 row.appendChild(td);
 tbody.appendChild(row);
 
 
 row = document.createElement('tr');
 
 row.setAttribute('class', 'addprow');
 row.setAttribute('style', 'display:none');
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Value:');
 row.appendChild(td);
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 var myinput = document.createElement('input');
 myinput.setAttribute('class', 'trns_pattern_eventinput ' + vtasbDivs2[i]);
 myinput.setAttribute('style', 'width:100px;');
 td.appendChild(myinput);
 row.appendChild(td);
 
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Display Name:');
 row.appendChild(td);
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 myinput = document.createElement('input');
 myinput.setAttribute('class', 'trns_pattern_Display_Name ' + vtasbDivs2[i]);
 myinput.setAttribute('style', 'width:100px;');
 
 td.appendChild(myinput);
 row.appendChild(td);
 tbody.appendChild(row);
 
 table.appendChild(tbody);
 divd2.appendChild(table);
 alldivs.appendChild(divd2);
 
 }
 
 
 
 return alldivs;
 }
 
 function  createVerticalTabs() {
 
 var alldivs = document.createElement('div');
 
 for (i = 0; i < vtasbDivs1.length; i++) {
 
 
 
 
 var divd1 = document.createElement('div');
 
 divd1.setAttribute('class', ' alldvs ' + vtasbDivs1[i]);
 
 if (i > 0) {
 
 
 divd1.setAttribute('style', ' display:none ');
 
 }
 
 
 
 var table = document.createElement('table');
 table.style.width = '100%';
 table.style.height = '100%';
 var tbody = document.createElement('tbody');
 
 row = document.createElement('tr');
 
 
 
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Event:');
 row.appendChild(td);
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 var myinput = document.createElement('input');
 myinput.setAttribute('class', 'tarns_eventinput ' + vtasbDivs1[i]);
 myinput.setAttribute('style', 'width:100px;');
 td.appendChild(myinput);
 row.appendChild(td);
 
 
 
 
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 mxUtils.write(td, 'Display Name:');
 row.appendChild(td);
 td = document.createElement('td');
 td.style.fontSize = '10pt';
 myinput = document.createElement('input');
 myinput.setAttribute('class', 'tarns_Display_Name ' + vtasbDivs1[i]);
 myinput.setAttribute('style', 'width:100px;');
 
 td.appendChild(myinput);
 row.appendChild(td);
 
 tbody.appendChild(row);
 table.appendChild(tbody);
 divd1.appendChild(table);
 
 alldivs.appendChild(divd1);
 
 
 }
 
 return alldivs;
 
 }
 
 function getVerticalTabs2Data() {
 
 
 var returnData = "";
 
 
 for (i = 0; i < vtasbDivs2.length; i++) {
 
 
 var ival = $(".tarns_eventinputs ." + vtasbDivs2[i]).val();
 var icom = vtasbDivs2[i];
 
 
 $("." + vtasbDivs2[i] + ".tarns_getinputData").remove();
 
 if ($.trim($(".tarns_eventinputs." + vtasbDivs2[i]).val()) != "") {
 var tvalue = "getselectData__event__display-name;" + vtasbDivs2[i] + "__" + $(".tarns_eventinputs." + vtasbDivs2[i]).val() + "__" + $(".tarns_Display_Names." + vtasbDivs2[i]).val();
 returnData += "\n" + returnInputField("__tarnsData  " + vtasbDivs2[i] + "  tarns_getinputData", tvalue);
 }
 
 
 
 
 
 
 
 var merEventdata = 0;
 
 
 
 $(".trns_more_event." + vtasbDivs2[i]).each(function() {
 merEventdata++;
 
 
 if ($(this).val() != "") {
 
 var value = "value__display-name;" + $(".trns_more_event." + vtasbDivs2[i]).eq(merEventdata - 1).val() + "__" + $(".trns_more_DisplayName." + vtasbDivs2[i]).eq(merEventdata - 1).val();
 returnData += "\n" + returnInputField("trns_more  trns_more  " + ival + "   " + icom + "  " + merEventdata, value);
 
 }
 
 });
 
 
 if ($.trim($(".trns_pattern_eventinput." + vtasbDivs2[i]).val()) != "") {
 
 
 tvalue = "event__display-name;" + $(".trns_pattern_eventinput." + vtasbDivs2[i]).val() + "__" + $(".trns_pattern_Display_Name." + vtasbDivs2[i]).val();
 returnData += "\n" + returnInputField("__tarnsData  " + ival + "   " + icom + " trns_pattern", tvalue);
 }
 }
 
 
 
 return returnData;
 
 
 }
 
 function getVerticalTabs1Data() {
 var returnData = "";
 
 for (i = 0; i < vtasbDivs1.length; i++) {
 
 
 $("." + vtasbDivs1[i] + ".tarns_getinputData").remove();
 
 
 var thist = $(".tarns_eventinput." + vtasbDivs1[i]).val();
 
 
 
 if ($.trim(thist) != "") {
 var tvalue = "getselectData__event__display-name;" + vtasbDivs1[i] + "__" + $(".tarns_eventinput." + vtasbDivs1[i]).val() + "__" + $(".tarns_Display_Name." + vtasbDivs1[i]).val();
 returnData += "\n" + returnInputField("__tarnsData  " + vtasbDivs1[i] + "  tarns_getinputData", tvalue);
 }
 }
 
 return returnData
 
 }
 
 */